#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::vector;

template <typename InputIterator, typename OutputIterator>
void my_merge(InputIterator first_begin, InputIterator first_end,
              InputIterator second_begin, InputIterator second_end, OutputIterator out_begin) {

    while (first_begin != first_end && second_begin != second_end) {
        if (*first_begin < *second_begin) {
            *out_begin = *first_begin;
            ++first_begin;
        } else {
            *out_begin = *second_begin;
            ++second_begin;
        }
        ++out_begin;
    }
    while (first_begin != first_end) {
        *out_begin = *first_begin;
        ++first_begin, ++out_begin;
    }

    while (second_begin != second_end) {
        *out_begin = *second_begin;
        ++second_begin, ++out_begin;
    }
}

void input(vector <int> &lst) {
    int n;
    cin >> n;
    lst.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> lst[i];
    }
}

void output(const vector <int> &lst) {
    for (size_t i = 0; i < lst.size(); i++) {
        cout << lst[i] << ' ';
    }
}

int main() {
    vector <int> first_lst, second_lst, output_lst;
    input(first_lst);
    input(second_lst);
    output_lst.resize(first_lst.size() + second_lst.size());
    my_merge(first_lst.begin(), first_lst.end(), second_lst.begin(), second_lst.end(),
             output_lst.begin());
    output(output_lst);
    return 0;
}
